package com.managertrade.service.sqllite.service;

import com.managertrade.dao.sqlite.entity.KlineWithIndicatorsEntity;
import com.managertrade.dto.vo.KlineWithIndicators;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Optional;

public interface KlineWithIndicatorsService {
    /**
     * 保存单条 Kline 数据
     */
    KlineWithIndicatorsEntity save(KlineWithIndicatorsEntity kline);

    /**
     * 批量保存 Kline 数据
     */
    List<KlineWithIndicatorsEntity> saveAll(List<KlineWithIndicatorsEntity> klines);

    /**
     * 根据 uniqueId 查询
     */
    Optional<KlineWithIndicatorsEntity> findById(String uniqueId);

    /**
     * 查询所有
     */
    List<KlineWithIndicatorsEntity> findAll();

    /**
     * 根据 uniqueId 删除
     */
    void deleteById(String uniqueId);

    /**
     * 根据 uniqueId 更新
     */
    KlineWithIndicatorsEntity updateById(String uniqueId, KlineWithIndicatorsEntity kline);

    public void saveIfNotExists(List<KlineWithIndicators> klineList);

    /**
     * 获取指定币种与周期的最新一条 K 线数据
     */
    KlineWithIndicatorsEntity findTopBySymbolAndPeriodOrderByTimestampDesc(String symbol, String period);

    List<KlineWithIndicatorsEntity>  findBySymbolAndPeriodPaged(String symbol, String period, Pageable pageable);

    List<KlineWithIndicatorsEntity> findLatestBySymbolAndPeriod(String symbol, String period);
}
